package com.shop.loan.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.shop.loan.channel.youxin.RSAEncrypUtil;
import com.shop.loan.mapper.UserByMybatisMapper;
import com.shop.loan.model.common.Code;
import com.shop.loan.model.common.ResResultByYouXin;
import com.shop.loan.model.entity.LoanOrderByMybatis;
import com.shop.loan.model.entity.UserByMybatis;
import com.shop.loan.model.vo.YouXinParamVo;
import com.shop.loan.service.LoanOrderService;
import com.shop.loan.service.YouXinService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

@Service
public class YouXinServiceImpl implements YouXinService {

    @Resource
    LoanOrderService loanOrderService;

    @Resource
    UserByMybatisMapper userByMybatisMapper;


    @Value("${api.youxin.channelId}")
    private Long channelId;

    //盈彩公钥
    @Value("${api.youxin.publicKey}")
    private String publicKey;

    //平台自己私钥
    @Value("${api.youxin.s_privateKey}")
    private String s_privateKey;

    @Override
    public ResResultByYouXin contractList(YouXinParamVo youXinParamVo) {
        if (!RSAEncrypUtil.buildRSAverifyByPublicKey(youXinParamVo.getData(), youXinParamVo.getSign(), publicKey)) {
            return new ResResultByYouXin(Code.SIGN_ERROR, null, null);
        }
        String desData = RSAEncrypUtil.buildRSADecryptByPrivateKey(youXinParamVo.getData(), s_privateKey);
        if (!StringUtils.hasLength(desData)) {
            return new ResResultByYouXin(Code.SIGN_ERROR, null, null);
        }
        JSONObject desDataJs = JSON.parseObject(desData);


        return null;
    }

    @Override
    public ResResultByYouXin userCheck(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin userCredit(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin creditResult(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin loanConfirm(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin loanStatus(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin repayPlan(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin repayConfirm(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin repayResult(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin getUrl(YouXinParamVo youXinParamVo) {
        return null;
    }

    @Override
    public ResResultByYouXin notifyOrderStatus(LoanOrderByMybatis loanOrderByMybatis, UserByMybatis userByMybatis) {
        return null;
    }

    @Override
    public void taskByNotify() {

    }
}
